package com.ssyt.ec.common;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ssyt.ec.exam.entity.AnswerEntity;

public class CountPoints {

	private CountPoints() throws IllegalAccessException {
		throw new IllegalAccessException();
	}

	public static Map<Integer, List<AnswerEntity>> answerMap = new HashMap<>();
	// static Map<考试安排id, Map<学员id, Map<试题id，答案>>> studentAnswerMap = new
	// HashMap<>();
	public static Map<Integer, Map<Integer, Map<Integer, String>>> studentAnswerMap = new HashMap<>();

	public static int getScores(int examPlanId, int studentId) {
		int scores = 0;
		List<AnswerEntity> answerList = answerMap.get(examPlanId);
		Map<Integer, String> singleStuAnswer = studentAnswerMap.get(examPlanId)
				.get(studentId);
		for (AnswerEntity answerEntity : answerList) {
			String stuAnswer = singleStuAnswer.get(answerEntity.getId());
			String rightAnswer = answerEntity.getAnswer();
			if (rightAnswer.equals(stuAnswer)) {
				scores += answerEntity.getScore();
			}
		}
		return scores;
	}
}
